package com.demo.spring.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

public interface TestService {

    String get(String key);

    void del(String key);

    @Slf4j
    @Service
    class Default implements TestService {

        @Cacheable(cacheNames="Test",key="#key")
        @Override
        public String get(String key) {

            log.info("no matched cache, get in method");

            return "1234567890";
        }

        @CacheEvict(cacheNames="Test",key="#key")
        @Override
        public void del(String key) {
            log.info("del,key={}",key);
        }

    }

}
